﻿<UserControl x:Class="Shelfmanager.BookView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d" 
             d:DesignHeight="420" d:DesignWidth="600">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="140"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="0" Text="ISBN" Margin="4"/>
        <TextBox Grid.Row="0" Grid.Column="1" Width="160" Text="{Binding ISBN,Mode=TwoWay}" Margin="2" HorizontalAlignment="Left"/>

        <TextBlock Grid.Row="1" Text="Title" Margin="4"/>
        <!--<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Title,Mode=TwoWay}" Margin="2" TextWrapping="Wrap"/>-->
        <ComboBox Grid.Row="1" Grid.ColumnSpan="10" Grid.Column="1" 
                  Text="{Binding Title,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="2,2,40,2" 
                  IsTextSearchEnabled="true" IsEditable="True" IsSynchronizedWithCurrentItem="True"
                  ItemsSource="{Binding BooksFound}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Title}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        <Button Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Width="24" Height="24" Margin="2,2,8,2" Command="{Binding SearchTitleCommand}">
            <Button.Content>
                <Grid>
                    <Line HorizontalAlignment="Right" VerticalAlignment="Bottom" X1="16" Y1="16" X2="22" Y2="22"  StrokeThickness="3" Stroke="Black" />
                    <Ellipse HorizontalAlignment="Left" VerticalAlignment="Top" Width="13" Height="13" Stroke="Black" StrokeThickness="2"/>
                </Grid>
            </Button.Content>
        </Button>
        <TextBlock Grid.Row="2" Text="Author(s)" Margin="4"/>
        <StackPanel Grid.Row="2" Grid.Column="1">

            <ListView ItemsSource="{Binding Authors}" Margin="2" Background="Transparent" BorderBrush="Transparent"
                      ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="2">
                            <TextBlock Width="12" Text=" " FontSize="18" FontWeight="Bold" VerticalAlignment="Center" />
                            <TextBox Text="{Binding Name,Mode=TwoWay}"/>
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
            <StackPanel Orientation="Horizontal">
                <TextBlock Width="12" Text="*" FontSize="22" FontWeight="Bold" VerticalAlignment="Center" />
                <TextBox Text="{Binding NewAuthor,Mode=TwoWay}" Margin="2" Width="200" HorizontalAlignment="Left"/>
                <Button Width="25" Height="25" Command="{Binding AddAuthorCommand}">
                    <Path Data="M5,0 L5,10 M0,5 L10,5" Fill="Black" StrokeThickness="3" Stroke="Black" />
                </Button>
            </StackPanel>
        </StackPanel>
        <TextBlock Grid.Row="3" Text="Publisher" Margin="4"/>
        <TextBox Grid.Row="3" Grid.Column="1" Width="160" Text="{Binding Publisher,Mode=TwoWay}" Margin="2" HorizontalAlignment="Left"/>
        <TextBlock Grid.Row="4" Text="Publicationdate" Margin="4"/>
        <TextBox Grid.Row="4" Grid.Column="1" Width="80" Text="{Binding PublicationDate,Mode=TwoWay}" Margin="2" HorizontalAlignment="Left"/>
        <TextBlock Grid.Row="5" Text="Language original" Margin="4"/>
        <TextBox Grid.Row="5" Grid.Column="1" Width="80" Text="{Binding LanguageOriginal,Mode=TwoWay}" Margin="2" HorizontalAlignment="Left"/>
        <TextBlock Grid.Row="6" Text="Language published" Margin="4"/>
        <TextBox Grid.Row="6" Grid.Column="1" Width="80" Text="{Binding LanguagePublished,Mode=TwoWay}" Margin="2" HorizontalAlignment="Left"/>
        <TextBlock Grid.Row="7" Text="Binding" Margin="4"/>
        <TextBox Grid.Row="7" Grid.Column="1" Width="120" Text="{Binding Binding,Mode=TwoWay}" Margin="2" HorizontalAlignment="Left"/>
        <TextBlock Grid.Row="8" Text="Number of pages" Margin="4"/>
        <TextBox Grid.Row="8" Grid.Column="1" Width="60" Text="{Binding NumberOfPages,Mode=TwoWay}" Margin="2" HorizontalAlignment="Left"/>
        <TextBlock Grid.Row="9" Text="Subject" Margin="4"/>
        <TextBox Grid.Row="9" Grid.Column="1" Width="160" Text="{Binding Subject,Mode=TwoWay}" Margin="2" HorizontalAlignment="Left"/>
        <TextBlock Grid.Row="10" Text="Class" Margin="4"/>
        <TextBox Grid.Row="10" Grid.Column="1" Width="60" Text="{Binding Class,Mode=TwoWay}" Margin="2" HorizontalAlignment="Left"/>
        <TextBlock Grid.Row="11" Text="Detailpage" Margin="4"/>
        <TextBox Grid.Row="11" Grid.Column="1" TextWrapping="Wrap" Text="{Binding DetailPageUrl,Mode=TwoWay}" Margin="2,2,218,2" />
        <Border Grid.Row="3" Grid.Column="1" Grid.RowSpan="20" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8" 
                BorderBrush="Gray" BorderThickness="1" Background="Silver">
            <Image  Source="{Binding Image}" Width="196"/>
        </Border>
      
    </Grid>
</UserControl>
